import * as React from 'react';
import { Form, Row, Col, Input, Button, Icon, DatePicker, Select, Table, message } from 'antd';
import { CAMLFilter, CAMLCompare, CamlQuery, SPDataType, CamlParam, CamlOrderBy } from './../../config/CAMLHelper';

const { Option } = Select;

import * as moment from 'moment';
import './index.scss';
import { FormComponentProps } from 'antd/lib/form/Form'; //获取form表单的interface
import { ListGUID } from '../../config/ListGuid';
import Api from '../../config/api';
import { Item } from '@pnp/sp/items';
const urlHas = encodeURI('/sites/zhuhuaHT/TestLib/2019/sss 台账/sss100-01');
const urlNotHas = encodeURI('/sites/zhuhuaHT/TestLib/2020');
const noFloderSaveFile = encodeURI('/sites/zhuhuaHT/TestLib/2021');
const urlFile = encodeURI('/sites/zhuhuaHT/TestLib/2010/test.html');
const layout = {
  labelCol: {
    span: 4
  },
  wrapperCol: {
    offset: 1,
    span: 19
  }
};

const phoneValidator = (rule: any, value: any, callback: any) => {
  if (!value) {
    callback('请输入！');
  }
  // 必须总是返回一个 callback，否则 validateFields 无法响应
  callback();
};

// 测试代码，调试API使用
class MyTestPage extends React.Component<FormComponentProps> {
  constructor(props: any & FormComponentProps) {
    super(props);
  }
  //提交按钮触发
  submit = e => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        this.getSubmit();
        
        
      }
    });
  };

  // 作废按钮触发
  invalid = () => {
    
    
  };
  // 草稿按钮触发
  theDraft = () => {
    
  };
  // 关闭按钮触发
  shutDown = () => {
    
  };

  // 法务受理日
  onChange = (date, dateString) => {
    this.setState({
      form: {
        ...this.state.form,
        date: dateString
      }
    });
  };
  // 法务最后回答日
  onChange1 = (date, dateString) => {
    this.setState({
      form: {
        ...this.state.form,
        date1: dateString
      }
    });
  };
  state = {
    //表单数据对象
    form: {
      // 法务受理日
      date: '',
      // 法务最后回答日
      date1: '',
      // 语言
      language: null,
      // 合同名称
      theContract: null,
      // 关键词1
      keywords1: null,
      // 关键词2
      keywords2: null,
      // 合同修改性质
      modification: null,
      // 相对方
      otherSide: null,
      // 社内依赖者名
      community: null,
      // 其他
      other: null,
      // 合同编号
      contract: '',
      // 决裁编号
      cutNumber: '',
      // 审查担当
      reviewOn: null,
      // 文件保存
      file: null,

      //下拉选择
      //问题
      problem: undefined,
      //性质
      nature: undefined,
      //期限
      term: undefined,
      //重要性
      importance: undefined,
      //我方
      we: undefined,
      //资质
      qualifications: undefined,
      //律师审查
      examination: undefined,
      //审查担当
      reviewOnxuan: [],
      //所属公司
      company: undefined,
      //所属部门
      department: undefined
    },
    //问题
    problemList: [],
    //合同性质
    natureList: [],
    //合同期限
    termList: [],
    //合同重要性
    importanceList: [],
    //我方
    weList: [],
    //资质
    qualificationsList: ['有', '无'],
    //律师审查
    LawyerList: [],
    //所属公司
    companyList: ['SEM', 'SEMW', 'SEMX'],
    //所属部门
    departmentList: [],
    //审查担当
    personreviewList: []
  };

  // 输入框改变赋值
  change(e, key) {
    
    this.setState({
      form: {
        ...this.state.form,
        [key]: e.target.value
      }
    });
  }
  // 下拉框改变赋值
  handleSelectChange(e, key) {
    
    
    this.setState({
      form: {
        key: e,
        ...this.state.form,
        [key]: e
      }
    });
    
  }
  onSelect(e) {
    
  }

  // onChange(value) {
  //   
  // }

  onBlur() {
    
  }

  onFocus() {
    
  }

  onSearch(val) {
    
  }



  //动态更新绑定数据
  public async componentDidMount() {


let total=[];//我要把每次循环的新数组加进来

for (let i = 0; i < 10; i++) {
    const element = [1,2,3,4];


// 把element 这个数组加到  total中
    
}













    let res1 = await Api._search({ Querytext: '龙' });
    
    var teststudent = await Api.GetListItemsByListGUID('d58ddb14-30f0-46c3-ab56-e9155728156c');
    
    var cu = await Api._getcurrentUser();
    var p1 = await Api.GetUserProperties('liuyumei@yuchentech.onmicrosoft.com');
    var vDep = '';
    var props = p1.UserProfileProperties;
    if (props && props.length > 0) {
      for (let i = 0; i < props.length; i++) {
        const element = props[i];
        if (element.Key == 'Department') {
          vDep = element.Value;
          break;
        }
      }
    }
    
    
    
    var a1test = await Api._getfileByGUID({ Guid: '6a57a020-549e-4aef-b354-8b6e39ff4f15', filter: '' });

    let camlQuery = {
      ViewXml: ''
    };
    camlQuery.ViewXml = `
    <View>
        <Query>
            <Where>            
                <Eq>
                    <FieldRef Name="FSObjType"></FieldRef>
                    <Value Type="Integer">0</Value>
                </Eq>             
            </Where>
        </Query>
    </View>             
      `;
    //   camlQuery.ViewXml=`
    //   <View>
    //       <Query>
    //           <Where>
    //               <And>
    //                   <Contains>
    //                       <FieldRef Name="FileLeafRef"></FieldRef>
    //                       <Value Type="Text">合同</Value>
    //                   </Contains>
    //                   <Eq>
    //                       <FieldRef Name="FSObjType"></FieldRef>
    //                       <Value Type="Integer">0</Value>
    //                   </Eq>
    //               </And>
    //           </Where>
    //       </Query>
    //   </View>
    //     `;

    let Naturcontract1 = await Api.GetListItemsByCAMLQuery('6a57a020-549e-4aef-b354-8b6e39ff4f15', camlQuery);
    //这里竟然能模糊查询
    let ppppp = await Api._getfileByGUID({ Guid: '6a57a020-549e-4aef-b354-8b6e39ff4f15', filter: 'FSObjType eq 0' });
    // filter: "FSObjType eq 0 and substringof('同导',FileLeafRef)" });
    

    
    let params: CamlParam[] = [];
    let count: number = 10;
    for (let i = 0; i < count; i++) {
      let item: CamlParam = new CamlParam('Title', String(i), SPDataType.Text, CAMLCompare.Eq);
      params.push(item);
    }

    //不排序
    let xmlText = Api.buildCamlXml(params);
    //根据年龄字段正排
    let orderAge: CamlOrderBy = new CamlOrderBy('Age', 'True');
    let test1 = Api.buildCamlXml(params, orderAge);

    //根据标题字段倒排
    orderAge = new CamlOrderBy('Title', 'False');
    let test2 = Api.buildCamlXml(params, orderAge);
    
    this.setButtonsEventHandlers();
    this.getTest(); // 测试代码，调试API使用
  }
  //编号 生成 我方+年+3位自增长序号
  //   合同/{年度}/{公司别}/{合同编号} [{申请书序列号}]
  public render(): React.ReactElement {
    const { getFieldDecorator } = this.props.form;
    const prefixSelector = (
      <Select allowClear  style={{ width: 130 }}>
        {this.state.personreviewList.map(element => {
          return (
            <Option value={element} key={element}>
              {element}
            </Option>
          );
        })}
      </Select>
    );

    return (
      <div className="box">
        <div className="box_content">
          <Input allowClear title="" style={{ width: '700px' }} placeholder="附件" type="file" id="fileUploadInput" name="myfile" />
          <Row align="middle" justify="end">
            <Col span={24}>
              <div className="flex">
                <div className="heTong"></div>
                <div className="het">新合同编号</div>
              </div>
            </Col>
          </Row>
          <Row type="flex" justify="space-between">
            <Col span={17}></Col>
            <Col span={1}>
              <Button type="default" className="Button_1" onClick={this.invalid}>
                作废
              </Button>
            </Col>
            <Col span={1} offset={1}>
              <Button type="primary" className="Button_2" onClick={this.submit}>
                提交
              </Button>
            </Col>
            <Col span={1} offset={1}>
              <Button type="primary" className="Button_3" onClick={this.theDraft}>
                草稿
              </Button>
            </Col>
            <Col span={1} offset={1}>
              <Button type="primary" onClick={this.shutDown}>
                关闭
              </Button>
            </Col>
          </Row>
          <div className="top"></div>
          <Form {...layout} name="login" layout="inline">
            <Row type="flex" justify="space-between">
              <Col span={11}>
                <Form.Item label="合同编号" labelAlign="right">
                  <Select allowClear 
                    showSearch
                    style={{ width: 200 }}
                    placeholder="Select a person"
                    optionFilterProp="children"
                    onChange={this.onChange}
                    onFocus={this.onFocus}
                    onBlur={this.onBlur}
                    onSearch={this.onSearch}
                    filterOption={(input, option: any) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  >
                    <Option value="jack">Jack</Option>
                    <Option value="lucy">Lucy</Option>
                    <Option value="tom">Tom</Option>
                  </Select>
                </Form.Item>
              </Col>
              <Col span={2}>
                <Form.Item>
                  <Button type="primary" className="Button_3" onClick={this.generateNumber}>
                    生成编号
                  </Button>
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label="语言" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    value={this.state.form.language}
                    onChange={event => {
                      this.change(event, 'language');
                    }}
                  />
                </Form.Item>
              </Col>
              <Col span={11}>
                <Form.Item label="法务受理日" labelAlign="right">
                  {getFieldDecorator('data', {
                    rules: [
                      {
                        validator: phoneValidator,
                        required: true
                      }
                    ]
                  })(<DatePicker allowClear  style={{ width: '100%' }} placeholder="请选择年份" onChange={this.onChange} format="YYYY/MM/DD" />)}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="问题" labelAlign="right">
                  {/* {
                    getFieldDecorator('problem', {
                      initialValue: this.state.form.problem
                    })(<Select allowClear 
                      placeholder="请选择"
                    >
                      {
                        this.state.problemList.map(element => {
                          return <Option value={element.Title} key={element.ID}>{element.Title}</Option>
                        })
                      }
                    </Select>)
                  } */}
                  <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.problem}
                    onChange={event => {
                      this.handleSelectChange(event, 'problem');
                    }}
                  >
                    {this.state.problemList.map(element => {
                      return (
                        <Option value={element.ID} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                    {/* <Option value="male">问题1</Option>
                    <Option value="female">问题2</Option> */}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="法务最后回答日" labelAlign="right">
                  <DatePicker allowClear  style={{ width: '100%' }} placeholder="请选择年份" onChange={this.onChange1} format="YYYY/MM/DD" />
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="合同性质" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.nature}
                    onChange={event => {
                      this.handleSelectChange(event, 'nature');
                    }}
                  >
                    {this.state.natureList.map(element => {
                      return (
                        <Option value={element.ID} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="合同名称" labelAlign="right">
                  {getFieldDecorator('theContract', {
                    rules: [
                      {
                        validator: phoneValidator,
                        required: true
                      }
                    ],
                    initialValue: this.state.form.theContract
                  })(
                    <Input
                      placeholder="请输入内容"
                      onChange={event => {
                        this.change(event, 'theContract');
                      }}
                    />
                  )}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="合同期限" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.term}
                    onChange={event => {
                      this.handleSelectChange(event, 'term');
                    }}
                  >
                    {this.state.termList.map(element => {
                      return (
                        <Option value={element.ID} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="关键词1" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    allowClear
                    value={this.state.form.keywords1}
                    onChange={event => {
                      this.change(event, 'keywords1');
                    }}
                  />
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="合同重要性" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择内容"
                    defaultValue={this.state.form.importance}
                    onChange={event => {
                      this.handleSelectChange(event, 'importance');
                    }}
                  >
                    {this.state.importanceList.map(element => {
                      return (
                        <Option value={element.ID} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="关键词2" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    allowClear
                    value={this.state.form.keywords2}
                    onChange={event => {
                      this.change(event, 'keywords2');
                    }}
                  />
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="合同修改性质" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    allowClear
                    onChange={event => {
                      this.change(event, 'modification');
                    }}
                  />
                  {/* {
                    getFieldDecorator('modification', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: false,
                        }
                      ],
                      initialValue: this.state.form.modification
                    })()
                  } */}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="我方" labelAlign="right">
                  {getFieldDecorator('text', {
                    rules: [
                      {
                        validator: phoneValidator,
                        required: true
                      }
                    ],
                    initialValue: this.state.form.we
                  })(
                    <Select allowClear 
                      placeholder="请选择"
                      // defaultValue={this.state.form.we}
                      onChange={event => {
                        this.handleSelectChange(event, 'we');
                      }}
                    >
                      {this.state.weList.map(element => {
                        return (
                          <Option value={element.abbreviations} key={element.ID}>
                            {element.abbreviations}
                          </Option>
                        );
                      })}
                    </Select>
                  )}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="资质" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.qualifications}
                    onChange={event => {
                      this.handleSelectChange(event, 'qualifications');
                    }}
                  >
                    {this.state.qualificationsList.map(element => {
                      return (
                        <Option value={element} key={element}>
                          {element}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="相对方" labelAlign="right">
                  {getFieldDecorator('otherSide', {
                    rules: [
                      {
                        validator: phoneValidator,
                        required: true
                      }
                    ],
                    initialValue: this.state.form.otherSide
                  })(
                    <Input
                      placeholder="请输入内容"
                      allowClear
                      onChange={event => {
                        this.change(event, 'otherSide');
                      }}
                    />
                  )}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="律师审查" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.examination}
                    onChange={event => {
                      this.handleSelectChange(event, 'examination');
                    }}
                  >
                    {this.state.LawyerList.map(element => {
                      return (
                        <Option value={element.Title} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="社内依赖者名" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    allowClear
                    onChange={event => {
                      this.change(event, 'community');
                    }}
                  />
                  {/* {
                    getFieldDecorator('community', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: false,
                        }
                      ],
                      initialValue: this.state.form.community
                    })()
                  } */}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="决裁编号" labelAlign="right">
                  <Input allowClear disabled value={this.state.form.cutNumber} />
                  {/* {
                    getFieldDecorator('cutNumber', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: false,
                        }
                      ],
                      initialValue: this.state.form.cutNumber
                    })()
                  } */}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="所属公司" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.company}
                    onChange={event => {
                      this.handleSelectChange(event, 'company');
                    }}
                  >
                    {this.state.companyList.map(element => {
                      return (
                        <Option value={element} key={element}>
                          {element}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="审查担当">
                  <Input.Group compact>
                    <Select allowClear 
                      mode="multiple"
                      placeholder="请选择"
                      style={{ width: '28%' }}
                      defaultValue={this.state.form.reviewOnxuan}
                      onChange={event => {
                        this.handleSelectChange(event, 'reviewOnxuan');
                      }}
                      maxTagCount={1}
                    >
                      {this.state.personreviewList.map(element => {
                        return (
                          <Option value={element.ID} key={element.ID}>
                            {element.Title}
                          </Option>
                        );
                      })}
                    </Select>
                    {/* <Select allowClear  >
                    <Option value="Zhejiang">Zhejiang</Option>
                    <Option value="Jiangsu">Jiangsu</Option>
                  </Select> */}
                    <Input allowClear style={{ width: '72%' }} placeholder="请输入内容" disabled />
                  </Input.Group>
                  {/* <Input allowClear addonBefore={prefixSelector} style={{ width: '100%' }} 
                  placeholder="请输入内容" onChange={(event) => { this.change(event, "reviewOn") }}/> */}
                  {/* {getFieldDecorator('reviewOn', {
                    rules: [{ required: true, message: '请输入内容' }],
                    initialValue: this.state.form.reviewOn
                  })()} */}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="所属部门" labelAlign="right">
                  <Select allowClear 
                    placeholder="请选择"
                    defaultValue={this.state.form.department}
                    onChange={event => {
                      this.handleSelectChange(event, 'department');
                    }}
                  >
                    {this.state.departmentList.map(element => {
                      return (
                        <Option value={element.Title} key={element.ID}>
                          {element.Title}
                        </Option>
                      );
                    })}
                  </Select>
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="文件保存" labelAlign="right">
                  <Input allowClear disabled value={this.state.form.file} />
                  {/* {
                    getFieldDecorator('file', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: false,
                        }
                      ],
                      initialValue: this.state.form.file
                    })(<Input allowClear disabled />)
                  } */}
                </Form.Item>
              </Col>

              <Col span={11}>
                <Form.Item label="其他" labelAlign="right">
                  <Input
                    placeholder="请输入内容"
                    allowClear
                    onChange={event => {
                      this.change(event, 'other');
                    }}
                  />
                  {/* {
                    getFieldDecorator('other', {
                      rules: [
                        {
                          validator: phoneValidator,
                          required: false,
                        }
                      ],
                      initialValue: this.state.form.other
                    })(<Input allowClear placeholder="请输入内容" onChange={(event) => { this.change(event, "other") }} />)
                  } */}
                </Form.Item>
              </Col>
            </Row>
          </Form>
        </div>
      </div>
    );
  }
  //合同性质 合同期限 合同重要性 律师审查 审查担当  公司设置  问题 部门列表
  //访问list NaturcontractGUID,ContractperiodGUID,ContractimportanceGUID,LawyerreviewGUID,PersonGUID,CompanysettingsGUID,ProblemGUID,DepartmentlstGUID
  public async getTest() {
    var _that = this;
    var param = {
      Guid: ListGUID.ContractNature //合同性质
    };
    let Naturcontract = await Api._getModel(param);

    var param1 = {
      Guid: ListGUID.ContractPeriod //合同期限
    };
    let Contractperiod = await Api._getModel(param1);
    // _that.state.termList = Contractperiod

    var param2 = {
      Guid: ListGUID.ContractImportance //合同重要性
    };
    let Contractimportance = await Api._getModel(param2);
    //_that.state.importanceList = Contractimportance

    var param3 = {
      Guid: ListGUID.LawerReview //律师审查
    };
    let Lawyerreview = await Api._getModel(param3);
    // _that.state.LawyerList = Lawyerreview

    var param4 = {
      Guid: ListGUID.Companies // 公司设置
    };
    let Companysettings = await Api._getModel(param4);
    // _that.state.weList = Companysettings

    var param5 = {
      Guid: ListGUID.Question // 问题
    };
    let Problem = await Api._getModel(param5);
    // _that.state.problemList = Problem

    var param6 = {
      Guid: ListGUID.Departments //部门列表
    };
    let Departmentlst = await Api._getModel(param6);

    var param7 = {
      Guid: ListGUID.ReviewOn //审查担当
    };
    let Person = await Api._getModel(param7);

    // _that.state.problemList = Departmentlst
    this.setState({
      natureList: Naturcontract,
      termList: Contractperiod,
      importanceList: Contractimportance,
      LawyerList: Lawyerreview,
      weList: Companysettings,
      problemList: Problem,
      personreviewList: Person,
      departmentList: Departmentlst
    });
  }

  private setButtonsEventHandlers(): void {
    //此处尝试点击按钮的时候再把附件添加到attachment上。
    let fileUpload = document.getElementById('fileUploadInput');
    if (fileUpload) {
      fileUpload.addEventListener('change', () => {
        this.uploadFiles(fileUpload);
      });
    }
  }

  private async uploadFiles(fileUpload) {
    var userInfo = await Api.GetUserByEmail('liuyumei@yuchentech.onmicrosoft.com');
    //await Api.GetUserProperties();
    
    // let file = fileUpload.files[0];
    // // const urlHas =  encodeURI( "/sites/zhuhuaHT/TestLib/2019/sss 台账/sss100-01");有这个文件夹,中文名称
    // // const urlNotHas=encodeURI( "/sites/zhuhuaHT/TestLib/2020");//没有该文件夹
    // // const noFloderSaveFile=encodeURI( "/sites/zhuhuaHT/TestLib/2021");//没有该文件夹准备直接存储文件
    // // const urlFile=encodeURI( "/sites/zhuhuaHT/TestLib/2010/test.html");//有这个文件
    // var url1 = '/sites/zhuhuaHT/TestLib/2010';
    // var a1 = await Api.action1(urlNotHas);
    // var a2 = await Api.action1(url1);
    // var a3 = await Api.action1('/sites/zhuhuaHT/TestLib/2019/sss 台账/sss100-01'); // 直接用中文名称取，不转码；
    // var a4 = await Api.action1(urlHas); // 转码后取
    // var a5=await Api._addfiles(file,"/sites/zhuhuaHT/TestLib/2019/sss 台账/sss100-01");//给不转码的带中文的文件夹中存储
    // var a6=await Api._addfiles(file,"/sites/zhuhuaHT/TestLib/2021");//没有该文件夹，看是否能存储成功（是否会自动生产文件夹）
    // var a7=await Api._addfiles(file,"/sites/zhuhuaHT/TestLib/2019");//有，看是否能存储成功
    // 
    // 
    // 
    // 
    // // 
    // // 
    // // 
    // var url8 = '/sites/zhuhuaHT/TestLib/2021';
    // var a8 = await Api.checkAndCreateFolder(url8); //没有该文件夹，会自动创建下级目录
    // var url11 = '/sites/zhuhuaHT/TestLib/2021/Test1/Test3/test4'; //层级也没这么深，也没文件夹，看是否能创建
    // var tt1 = await Api.checkAndCreateFolder(url11); //暂时不支持跨层级
    // 
    // 
    // 

    // var attObj = {};
    // if (file) {
    //   var fSize = file.size;
    //   var maxSize = 20 * 1024 * 1024; //限制20M

    //   var fileName = file.name;
    //   //判断空文件
    //   if (fSize == 0) {
    //   }

    //   //判断文件名称合法
    //   if (fileName.indexOf('.') > -1 || fileName.indexOf('%') > -1 || fileName.indexOf('#') > -1 || fileName.indexOf('+') > -1) {
    //     //排除 .
    //     if (fileName.indexOf('.') > -1) {
    //       let firstCodePosition = fileName.indexOf('.');
    //       let lastCodePosition = fileName.lastIndexOf('.');

    //       if (firstCodePosition != lastCodePosition) {
    //         //
    //         let errorMsgInfo = `所上传的文件名称包含特殊字符‘.’，不允许上传，请修改文件名称后重新上传`;

    //         return;
    //       }
    //     }

    //     //排除 % # +
    //     if (fileName.indexOf('%') > -1 || fileName.indexOf('#') > -1 || fileName.indexOf('+') > -1) {
    //       let errorMsgInfo = `所上传的文件名称包含特殊字符‘%、#、+’，不允许上传，请修改文件名称后重新上传`;

    //       return;
    //     }
    //   }

    //   //判断文件名称超长
    //   if (fileName.length >= 44) {
    //     //根据现有路径判断不要超长
    //     let errorMsgInfo = `所上传的文件名称超过40个字符，请修改文件名称后重新上传`;

    //     return;
    //   }

    //   //判断文件名称是否存在【文件夹下没有同名文件】
    //   var items = [];
    //   let canContinueSubmit: boolean = true;
    //   if (items.length > 0) {
    //     //已有记录时，查看这些记录是否状态都是拒绝的
    //   }
    // } else {
    //   attObj = { FileName: '', FileObj: '' };
    // }
  }

  //提交合同
  public async getSubmit() {
    //  添加新合同
    var pa = {
      Guid: ListGUID.StandingBook, //变更申请
      Obj: {
        LinkTitle: this.state.form.contract, //合同编号
        AcceptTime: this.state.form.date, //法务受理日
        Language: this.state.form.language, //语言
        Problem: this.state.form.problem, //问题
        LastAnswerTime: this.state.form.date1, //法务最后回答
        ContractNatureID: this.state.form.nature, //合同性质
        ContractName: this.state.form.theContract, //合同名称
        ContractDeadlineID: this.state.form.term, //合同期限
        Keyword1: this.state.form.keywords1, //关键1
        ContractSignificanceID: this.state.form.importance, //合同重要性
        Keyword2: this.state.form.keywords2, //关键2
        ContactEditNature: this.state.form.modification, //合同修改性质
        Our: this.state.form.we, //我方
        Qualifications: this.state.form.qualifications, //资质
        Counterparty: this.state.form.otherSide, //相对方
        LawyerReviewID: this.state.form.examination, //律师审查
        RelierName: this.state.form.community, //社内依赖者
        BelongsCompany: this.state.form.company, //所属公司
        ReviewOnID: this.state.form.reviewOnxuan.join(','), //审查担当
        BelongsDepartment: this.state.form.department, //所属部门
        FileAddress: this.state.form.file, //文件保存路径
        Other: this.state.form.other //其它
      }
    };
    
    return;
  }
  //生成编号
  public async generateNumber() {
    var sss = 'ssxxx';
    var param4 = {
      Guid: ListGUID.StandingBook, // 公司设置
      Top: 0,
      Filter: "LinkTitle eq '" + sss + "'"
    };
    let Companysettings = await Api._getModelli(param4);
  }
}
export default Form.create()(MyTestPage);
